import request from '@/utils/request'
import { PageDate } from '@/model'
import { ServerDTO } from '@/model/efficient/ServerDTO'
/**
 * 获取应用分页
 * @param data
 * @returns
 */
export function serverPage(params): Promise<PageDate<ServerDTO>> {
  return request.get('/api/efficient/server/page', params)
}

export function serverRemove(id: number) {
  return request.delete(`/api/efficient/server/${id}`)
}

export function serverSave(data: ServerDTO) {
  return request.post('/api/efficient/server', data)
}

export function serverUpdate(data: ServerDTO) {
  return request.put(`/api/efficient/server/${data.id}`, data)
}

/**
 * 获取所有服务器
 */
export function getAllServer() : Promise<Array<ServerDTO>> {
  return request.get('/api/efficient/server/getAll')
}

/**
 * 根据环境id获取所有服务
 */
export function getByEnvironment(environmentId: number): Promise<Array<ServerDTO>> {
  return request.get('/api/efficient/server/getByEnvironment', {
    environmentId,
  })
}
